using System;
using System.Data;
using System.Data.SqlClient;

namespace ProcessesSMS
{
	/// <summary>
	/// Summary description for SMS_SORTCODE.
	/// </summary>
	public class SMS_SHORTCODE
	{
		#region Properties
		private int _CPID;
		public int CPID
		{
			get 
			{
				return _CPID;
			}
			set
			{
				_CPID=value;
			}
		}

		private int _DataType;
		public int DataType
		{
			get 
			{
				return _DataType;
			}
			set
			{
				_DataType=value;
			}
		}

		private int _DataID=-1;
		public int DataID
		{
			get 
			{
				return _DataID;
			}
			set
			{
				_DataID=value;
			}
		}
		
		
		private int _AdsID;
		public int AdsID
		{
			get 
			{
				return _AdsID;
			}
			set
			{
				_AdsID=value;
			}
		}

		private string _DataName;
		public string DataName
		{
			get 
			{
				return _DataName;
			}
			set
			{
				_DataName=value;
			}
		}
		

		private string _MediaCode;
		public string MediaCode
		{
			get 
			{
				return _MediaCode;
			}
			set
			{
				_MediaCode=value;
			}
		}
		

		private string _ShortCode;
		public string ShortCode
		{
			get 
			{
				return _ShortCode;
			}
			set
			{
				_ShortCode=value;
			}
		}
		private int _Status;
		public int Status
		{
			get 
			{
				return _Status;
			}
			set
			{
				_Status=value;
			}
		}
		#endregion
		public SMS_SHORTCODE()
		{
			//
			// TODO: Add constructor logic here
			//		
		}
		public SMS_SHORTCODE(string _scode)
		{
			//
			// TODO: Add constructor logic here
			//
			_ShortCode = _scode;
			_ShortCode = _ShortCode.Replace("'","");
			SMS_DB _DB=new SMS_DB(ConfigSettings.ReadSetting("mCMSConnStr"));
			string sSQL = "Select CPID, DataType, DataID, AdsID, DataName, MediaCode, ShortCode, Status From AdsContent Where ShortCode='" + _ShortCode + "'";
			DataSet mData = _DB.GetData(sSQL);
			if (mData.Tables[0].Rows.Count>0)
			{
				try
				{
					_AdsID = Convert.ToInt32(mData.Tables[0].Rows[0]["AdsID"].ToString());
					_CPID = Convert.ToInt32(mData.Tables[0].Rows[0]["CPID"].ToString());
					_DataID = Convert.ToInt32(mData.Tables[0].Rows[0]["DataID"].ToString());
					_DataName = mData.Tables[0].Rows[0]["DataName"].ToString();
					_DataType = Convert.ToInt32(mData.Tables[0].Rows[0]["DataType"].ToString());
					_MediaCode = mData.Tables[0].Rows[0]["MediaCode"].ToString();
					_Status = Convert.ToInt32(mData.Tables[0].Rows[0]["status"].ToString());
				}
				catch
				{}				
			}			
		}
		
	}
}
